#include<stdio.h>
int prime[100000002];
int prime1[6000010];
int cnt = 0;
void sf(int n){
    prime[1]=1;
    for(int i=2;i<=n;i++){
        if(!prime[i]){
            cnt++;
            prime1[cnt]=i;
        }
        for(int j=1;j<=cnt&&i*prime1[j]<=n;j++){
            prime[i*prime1[j]]=1;
            if(i%prime1[j]==0)break;
        }
    }
}
int main(){
    int n;
    int q;
    scanf("%d %d",&n,&q);
    sf(n);
    for(int i=1;i<=q;i++){
        int x;
        scanf("%d",&x);
        printf("%d\n",prime1[x]);
    }
    return 0;
}